/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DadosBD;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Rodrigo L. Benites
 */
@Entity
@Table(name = "PREREQ")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Prereq.findAll", query = "SELECT p FROM Prereq p"),
    @NamedQuery(name = "Prereq.findByDisciplina", query = "SELECT p FROM Prereq p WHERE p.prereqPK.disciplina = :disciplina"),
    @NamedQuery(name = "Prereq.findByPrereq", query = "SELECT p FROM Prereq p WHERE p.prereqPK.prereq = :prereq"),
    @NamedQuery(name = "Prereq.findByFamilia", query = "SELECT p FROM Prereq p WHERE p.familia = :familia")})
public class Prereq implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PrereqPK prereqPK;
    @Column(name = "FAMILIA")
    private Integer familia;

    public Prereq() {
    }

    public Prereq(PrereqPK prereqPK) {
        this.prereqPK = prereqPK;
    }

    public Prereq(String disciplina, String prereq) {
        this.prereqPK = new PrereqPK(disciplina, prereq);
    }

    public PrereqPK getPrereqPK() {
        return prereqPK;
    }

    public void setPrereqPK(PrereqPK prereqPK) {
        this.prereqPK = prereqPK;
    }

    public Integer getFamilia() {
        return familia;
    }

    public void setFamilia(Integer familia) {
        this.familia = familia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prereqPK != null ? prereqPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prereq)) {
            return false;
        }
        Prereq other = (Prereq) object;
        if ((this.prereqPK == null && other.prereqPK != null) || (this.prereqPK != null && !this.prereqPK.equals(other.prereqPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DadosBD.Prereq[ prereqPK=" + prereqPK + " ]";
    }
    
}
